﻿using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using Entitas;
using Game.Data;
using UnityEngine;

namespace Game
{
    public class GameItemView : ViewBase, IGameItemIndexListener
    {

        private float time;

        public override void Link(IEntity entity, IContext context)
        {
            base.Link(entity, context);
            gameEntity.AddGameItemIndexListener(this);
        }

        //移动 消除功能
        public void OnGameItemIndex(GameEntity entity, CustomVector2 index)
        {
            //移动具体代码
            transform.DOMove(new Vector3(index.x, index.y, 0), 0.3F);
        }

        public override void OnGameDestoryItem(GameEntity entity)
        {
            base.OnGameDestoryItem(entity);
            transform.DOScale(Vector3.one * 1.5f, time);
            transform.GetComponent<SpriteRenderer>().DOColor(Color.clear, time);

        }
    }
}

